#!/bin/bash

rm -rf /usr/java/git/java-common-pom
rm -rf /usr/java/git/sell-java-commom
rm -rf /usr/java/git/sell-shop-product-qualification
rm -rf /usr/java/git/sell-commodity
rm -rf /usr/java/git/sell-activity
rm -rf /usr/java/git/sell-user
echo '--------------------------------------------------------------------------'
echo '--------------------------------------------------------------------------'
echo '-------------------finished:rm git----------------------------------------'
echo '--------------------------------------------------------------------------'
echo '--------------------------------------------------------------------------'

cd /usr/java/git/
git clone http://git.culiu.org/xujiangtao/java-common-pom.git
git clone http://git.culiu.org/xujiangtao/sell-java-commom.git
git clone http://git.culiu.org/huangyk/sell-shop-product-qualification.git
git clone http://git.culiu.org/zhangyang/sell-commodity.git
git clone http://git.culiu.org/zhaoyang/sell-activity.git
git clone http://git.culiu.org/huangyk/sell-user.git
echo '--------------------------------------------------------------------------'
echo '--------------------------------------------------------------------------'
echo '-------------------finished:clone-----------------------------------------'
echo '--------------------------------------------------------------------------'
echo '--------------------------------------------------------------------------'

cd /usr/java/git/java-common-pom
mvn install -Dmaven.test.skip=true
cd /usr/java/git/sell-java-commom
mvn install -Dmaven.test.skip=true
cd /usr/java/git/sell-commodity
mvn install -Dmaven.test.skip=true
cd /usr/java/git/sell-user
mvn install -Dmaven.test.skip=true
cd /usr/java/git/sell-shop-product-qualification
mvn install -Dmaven.test.skip=true
cd /usr/java/git/sell-activity
mvn install -Dmaven.test.skip=true
echo '--------------------------------------------------------------------------'
echo '--------------------------------------------------------------------------'
echo '-------------------finished:mvn:install-----------------------------------'
echo '--------------------------------------------------------------------------'
echo '--------------------------------------------------------------------------'
[root@test-web-01 sid]# cat ./git-
git-activity.sh   git-commodity.sh  git-parent.sh     git-qua.sh        git-user.sh       
[root@test-web-01 sid]# cat ./git-commodity.sh 
#!/bin/bash

rm -rf /usr/java/git/sell-commodity
echo '--------------------------------------------------------------------------'
echo '--------------------------------------------------------------------------'
echo '-------------------finished:rm git/sell-commodity-------------------------'
echo '--------------------------------------------------------------------------'
echo '--------------------------------------------------------------------------'

cd /usr/java/git/
git clone http://git.culiu.org/zhangyang/sell-commodity.git
echo '--------------------------------------------------------------------------'
echo '--------------------------------------------------------------------------'
echo '-------------------finished:clone:sell-commodity--------------------------'
echo '--------------------------------------------------------------------------'
echo '--------------------------------------------------------------------------'

cd /usr/java/git/sell-commodity
mvn install
echo '--------------------------------------------------------------------------'
echo '--------------------------------------------------------------------------'
echo '-------------------finished:mvn:install:commodity-------------------------'
echo '--------------------------------------------------------------------------'
echo '--------------------------------------------------------------------------'

targetpath='/usr/java/sell-service'
sourcepath='/usr/java/git/sell-commodity'

SELLCOMMODITY=$(cat /var/run/sell-commodity.pid)
kill $SELLCOMMODITY
echo '--------------------------------------------------------------------------'
echo '--------------------------------------------------------------------------'
echo '-------------------finished:kill:jar--------------------------------------'
echo '--------------------------------------------------------------------------'
cp -f ${sourcepath}/service/target/sell-commodity.jar ${targetpath}/sell-commodity/sell-commodity.jar
echo '--------------------------------------------------------------------------'
echo '-------------------finished:cp:jar----------------------------------------'
echo '--------------------------------------------------------------------------'

cp -f ${sourcepath}/web/target/sell-commodity.war ${targetpath}/sell-tomcat/webapps/sellcommodity.war
echo '--------------------------------------------------------------------------'
echo '-------------------finished:cp:war----------------------------------------'
echo '--------------------------------------------------------------------------'

JAVA_OPTS="-Xms128m -Xmx256m"
java $JAVA_OPTS -jar ${targetpath}/sell-commodity/sell-commodity.jar test >/dev/null &
echo $! > /var/run/sell-commodity.pid
echo '--------------------------------------------------------------------------'
echo '-------------------finished:run:jar---------------------------------------'
echo '--------------------------------------------------------------------------'

wait
echo "All is ok"
exit 0
